<?php if ($this->full_page) : ?>
<?php echo $this->render('layouts/__header.phtml'); ?>
<?php echo $this->render('layouts/__nav.phtml'); ?>
<link rel="stylesheet" type="text/css" href="/css/task.css" />
<?php endif; ?>

<h2>Detail of Task <?php echo $this->task['id']?>&nbsp;&nbsp;<a href="/task/edit/id/<?php echo $this->task['id']?>">edit the task</a></h2>
<table class="taskdetail">
<tr><td class="item">Title : </td><td><?php echo $this->HtmlEscape($this->task['title'])?></td></tr>
<tr><td class="item">Property : </td><td><?php echo $this->task['property']?></td></tr>
<tr><td class="item">Requester : </td><td><?php echo $this->task['requester']?></td></tr>
<tr><td class="item">PM : </td><td><?php echo $this->task['manager']?></td></tr>
<tr><td class="item">Assign To : </td><td><?php echo $this->task['developer']?></td></tr>
<tr><td class="item">Prior Refer : </td><td><?php echo $this->task['prior']?></td></tr>
<tr><td class="item">Type : </td><td><?php echo $this->task['type']?></td></tr>
<tr><td class="item">Status : </td><td><?php echo $this->task['status']?></td></tr>
<tr><td class="item">Progress : </td><td><img src="<?php echo $this->task['process']?>" class="processbar"/>&nbsp;<?php echo $this->task['progress']?></td></tr>
<tr><td class="item">Start Date : </td><td><?php echo $this->task['date_start']?></td></tr>
<tr><td class="item">Due Date : </td><td><?php echo $this->task['date_end']?></td></tr>
<tr><td class="item">Description : </td><td><?php echo $this->HtmlEscape($this->task['description'])?></td></tr>
<tr><td class="item" colspan='2'>Task Update : </td></tr>
<tr>
	<td colspan='2'>
		<?php
		foreach($this->task['task_updates'] as $task_update) {
			echo "
				<ul class='task_update'>
					<li class='task_update_user'>
						<a href='javascript:void(0);' onclick='showTaskUpdateDetail(this,{$task_update['id']});'>
							<img src='/images/expand.gif'>
						</a>
						{$task_update['username']}
					</li>
					<li class='task_update_time' align='right'>{$task_update['update_time']}</li>
				</ul>
				<ul id='stu-{$task_update['id']}' class='task_update_content'>
					<li>{$task_update['content']}</li>
				</ul>
				  ";	
		}
		?>
	</td>
</tr>
<tr><td class="item" colspan="2">Attachments : </td></tr>
<tr><td colspan="2">
<div id="attachment_box"><iframe id="upload_frame" name="upload_frame" src="<?php echo $this->upload_url; ?>" frameborder="0"></iframe></div>
</td></tr>
</table>
<table class="taskmessage">
<?php if ($this->task['developer'] != '--') : ?>
	<tr><td><b>Leave a message to <font color="blue"><?php echo $this->task['developer'] ?></font> : </b></td></tr>
	<tr><td style="padding-top:5px"><textarea id="content" name="content" rows="5" cols="35"></textarea></td></tr>
	<tr><td style="padding-top:5px"><input type="button" id="sendMessBtn" name="sendMessBtn" value="Send Message" onclick="javascript:sendMess()" /></td></tr>
	<script type="text/javascript">
	var request_uri = '<?php echo $this->mess_url;?>?t='+(new Date()).getTime();
	var sendMess = function () {
		$('loadingbox').setStyle('display', 'block');
		new Ajax(request_uri, {
			method: 'get',
			data: Object.toQueryString({
				taskid: <?php echo $this->task['id']?>,
				userid: <?php echo $this->user['userId']?>,
				toid: <?php echo $this->task['developer_id']?>,
				content: $('content').value
			}),
			onComplete: function(){
				$('loadingbox').setStyle('display', 'none');
				if ('success' != this.response.text) {
					alert('Your message sent failure!');
				} else {
					<?php if ($this->full_page) : ?>
					alert('Your message has been sent successfully!');
					<?php else : ?>
					PopBox.close();
					<?php endif; ?>
				}
			}
		}).request();
	}
	</script>
<?php else : ?>
	<tr><td><b>No developer to leave a message to ...</b></td></tr>
<?php endif; ?>
</table>

<?php if ($this->full_page) : ?>
<div id="loadingbox" style="display:none;padding:2px 0px 0px 8px;width:125px;height:20px;text-align:center;position:absolute;top:0px;right:0px;background:#CC0000;color:#fff;z-index:10000;"><b>Loading ...</b></div>
<?php echo $this->render('layouts/__footer.phtml'); ?>
<?php endif; ?>